/*
 * Powered By dico
 * Since 2017 - 2018
 */package com.seeyoui.kensite.bussiness.exam.paper.service;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.seeyoui.kensite.common.base.service.BaseService;

import java.util.*;

import com.seeyoui.kensite.common.base.domain.EasyUIDataGrid;
import com.seeyoui.kensite.common.base.service.BaseService;
import com.seeyoui.kensite.common.exception.CRUDException;
import com.seeyoui.kensite.common.util.*;
import com.seeyoui.kensite.common.constants.StringConstant;
import com.seeyoui.kensite.bussiness.exam.paper.domain.Paper;
import com.seeyoui.kensite.bussiness.exam.paper.persistence.PaperMapper;

/**
 * Paper
 * @author dico
 * @version 2.0
 * @since 1.0
 * @date 2018-01-08
 */

@Service
public class PaperService extends BaseService {
	
	@Autowired
	private PaperMapper paperMapper;

	/**
	 * 根据ID查询单条数据
	 * @param id
	 * @return
	 * @throws CRUDException
	 */
	public Paper findOne(String id) throws CRUDException{
		return paperMapper.findOne(id);
	}
	
	/**
	 * 根据考试ID查询单条数据
	 * @param examId
	 * @return Paper
	 */
	public Paper findByExamId(String examId) throws CRUDException{
		return paperMapper.findByExamId(examId);
	}
	
	/**
	 * 查询数据集合
	 * @param paper
	 * @return
	 * @throws CRUDException
	 */
	public List<Paper> findList(Paper paper) throws CRUDException {
		return paperMapper.findList(paper);
	}
	
	/**
	 * 查询所有数据集合
	 * @param paper
	 * @return
	 * @throws CRUDException
	 */
	public List<Paper> findAll(Paper paper) throws CRUDException {
		return paperMapper.findAll(paper);
	}
	
	/**
	 * 查询数据总数
	 * @param paper
	 * @return
	 * @throws CRUDException
	 */
	public int findTotal(Paper paper) throws CRUDException {
		return paperMapper.findTotal(paper);
	}
	
	/**
	 * 查询数据总数排除当前数据
	 * @param paper
	 * @return
	 * @throws CRUDException
	 */
	public int findExTotal(Paper paper) throws CRUDException {
		return paperMapper.findExTotal(paper);
	}
	
	/**
	 * 数据新增
	 * @param paper
	 * @throws CRUDException
	 */
	public String  save(Paper paper) throws CRUDException{
		paper.preInsert();
		paperMapper.save(paper);
		return paper.getId();
	}
	
	/**
	 * 数据修改
	 * @param paper
	 * @throws CRUDException
	 */
	public void update(Paper paper) throws CRUDException{
		paper.preUpdate();
		paperMapper.update(paper);			
	}
	
	/**
	 * 数据删除
	 * @param listId
	 * @throws CRUDException
	 */
	public void delete(List<String> listId) throws CRUDException {
		paperMapper.delete(listId);
	}
	
	/**
	 * 数据假删除
	 * @param paper
	 * @throws CRUDException
	 */
	public void remove(Paper paper) throws CRUDException{
		paper.preUpdate();
		paperMapper.remove(paper);			
	}
	
}